/*******************************************************************************
**
** Copyright (c) 2011 - The OWE Team
**
** This file is part of OWE.
**
** OWE is a free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; version
** version 2.1 of the License.
**
** OWE is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with OWE. If not, see <http://www.gnu.org/licenses/>.
**
*******************************************************************************/

#include <owe/ustring.h>
#include <owe/widgetpackage.h>

#include "widgetpackage_p.h"

OWE_USE_NAMESPACE

/*!
    \class WidgetPackagePrivate

    \skip
*/
WidgetPackagePrivate::WidgetPackagePrivate(const UString &path)
    : path(path)
{
}

/*!
    \class WidgetPackage
    \brief Widget package abstraction.

    \ingroup Packaging

    This class implements <a href="http://www.w3.org/TR/widgets/#widget-packages">
    packaging</a> section of the working in progress W3C draft
    <a href="http://www.w3.org/TR/widgets/">Widget Packaging & Configuration</a>.

    \todo The current implementation doesn't supports compressed (Zip) packages.
*/

/*!
    Constructs a new WidgetPackage from an uncompressed widget located at \a
    path. Only folders are supported by this constructor.
*/
WidgetPackage::WidgetPackage(const UString &path)
    : d_ptr(new WidgetPackagePrivate(path))
{
}

/*!
    Destructs the object releasing all allocated resources.
*/
WidgetPackage::~WidgetPackage()
{
    delete d_ptr;
}

/*!
    Check if the widget package is compliant with the rules of packaging
    validation as described in the
    <a href="http://www.w3.org/TR/widgets/#steps-for-processing-a-widget-package">
    W3C specification.</a> This will perform validation only with package
    related checks.

    Returns true if the package is valid, false otherwise.
*/
bool WidgetPackage::isValid() const
{
    return true;
}

/*!
    Returns the absolute path for a given \a file. This absolute path is
    generated considering folder localization rules as described <a
    href="http://www.w3.org/TR/widgets/#folder-based-localization">here</a>.
*/
UString WidgetPackage::getAbsolutePath(const UString &file) const
{
    return d_ptr->path + file;
}
